<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <script src="angular1.5.8.js"></script>
</head>
<body ng-app="frankApp" ng-controller="frankCtrl">
    <form name="frankForm">
        <input type="text" placeholder="用户名" ng-model="username" required><br>
        <input type="password" placeholder="密码" ng-model="password" required><br>
        <input type="checkbox" ng-checked="checks" ng-click="change()">记住密码<br>
        <button ng-click="submit()" ng-disabled="frankForm.$invalid">登录</button>
    </form>
</body>
<script>
    angular.module("frankApp",[]).controller("frankCtrl",function($scope){
        $scope.checks=false;
        $scope.change=function(){
            $scope.checks=!$scope.checks;
        }
        $scope.submit=function(){
            if($scope.checks){
                //存localStorage,并且存sessionStorage
                localStorage.setItem("username",$scope.username);
                localStorage.setItem("password",$scope.password);
            }
            sessionStorage.setItem("username",$scope.username);
            sessionStorage.setItem("password",$scope.password);
            location.href="index.html";
        }
    })
</script>
</html>